<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
	</head>
	<body>
		<textarea name="" id="message" cols="30" rows="10"></textarea>
		<button>提交</button>
		<div></div>
		<script>
			// 替换 replace
			let str = 'andy和red';
			// let newStr = str.replace('andy', 'baby');
			let newStr = str.replace(/andy/, 'baby');
			console.log(newStr);
			const text = document.querySelector('textarea');
			const btn = document.querySelector('button');
			const div = document.querySelector('div');
			btn.onclick = function () {
				div.innerHTML = text.value.replace(/妈|爸/g, '*');
			};
		</script>
	</body>
</html>
